{{- $cni_version := "1.4.0" }}
{{- $flannel_version := "1.1.2" }}
{{- $image_version := $cni_version | replace "." "-" }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $image_version }}
from: {{ $.Images.BASE_SCRATCH }}
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $image_version }}
  add: /
  to: /
  includePaths:
  - bandwidth
  - bridge
  - dhcp
  - dummy
  - firewall
  - host-device
  - host-local
  - ipvlan
  - loopback
  - macvlan
  - portmap
  - ptp
  - sbr
  - static
  - tap
  - tuning
  - vlan
  - vrf
  - flannel
  - install
  - uninstall
  before: setup
docker:
  LABEL:
    distro: all
    version: all
    kubernetes-cni: {{ $cni_version }}
    flannel: {{ $flannel_version }}
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $image_version }}
from: {{ $.Images.BASE_GOLANG_21_ALPINE_DEV }}
git:
- add: /{{ $.ModulePath }}modules/007-{{ $.ModuleName }}/images/{{ $.ImageName }}/scripts
  to: /
  stageDependencies:
    setup:
    - '**/*'
shell:
  setup:
    - export GOPROXY={{ $.GOPROXY }}
    - git clone --depth 1 --branch v{{ $cni_version }} {{ $.SOURCE_REPO }}/containernetworking/plugins.git
    - cd /plugins
    - CGO_ENABLED=0 ./build_linux.sh -ldflags '-extldflags -static -X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion={{ $cni_version }}'
    - cp -f bin/* /
    - cd /
    - git clone --depth 1 --branch v{{ $flannel_version }} {{ $.SOURCE_REPO }}/flannel-io/cni-plugin.git
    - cd /cni-plugin
    - make build_linux
    - cp -f  /go/src/github.com/flannel-io/cni-plugin/dist/flannel-amd64 /flannel
